<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="../js/jquery-1.10.2.js"></script>
	</head>

	<body>
		<input type="text" value="" id="PTotalMoney"  />
		<span>小数点最多四位</span>
		<script type="text/javascript">
			$('#PTotalMoney').bind('input propertychange', function() {
				var value = $(this).val()
				console.log(value)
				if(value == ''){
					return
				}
				if(!check_num(value)) {
					var new_money = value.substring(0, value.length - 1)
					$(this).val(new_money)
				}
			})

			function check_num(value) {			
				var reg = /^\d+(\.\d{0,4})?$/
				return reg.test(value)
			}
		</script>

	</body>

</html>